﻿<!--#include file="../Lib/base.asp"-->
<%

	dim act:act=lcase(Cls.fget("act",0))
	select case act
		case "check":check
		case "out":logout
		case else :main
	end select
	
	sub check()
		dim t0,t1,t2,t3
		t0=Cls.enhtml(Cls.fpost("t0",0))
		t1=Cls.enhtml(Cls.fpost("t1",0))
		t2=Cls.enhtml(Cls.fpost("t2",0))
		t3=Cls.loadsession("imgcode")
		if Cls.strlen(t0)=0 then Cls.echo "0用户名不能为空":exit sub
		if Cls.strlen(t1)=0 then Cls.echo "0密码不能为空":exit sub
		if Cls.strlen(t2)=0 then Cls.echo "0验证码不能为空":exit sub
		if Cls.strlen(t3)=0 then Cls.echo "0无法获取系统验证码":exit sub
		if t2<>t3 then Cls.echo "0验证码不正确":exit sub
		dim data
		data=Cls.db.dbload(1,"adminid,logintimes,islock,groupid,penname,lastlogindate,lastloginip","[sys_Admin]","adminname='"&t0&"' and adminpass='"&md5(t1)&"'","")
		if ubound(data)<0 then
			Cls.echo "0用户名或密码错误"
		else
			if data(2,0)=0 then
				Cls.echo "0用户被锁定，不能登录"
			else
				dim datanew
				datanew=array(array("logintimes",data(1,0)+1,0,0),array("lastlogindate",sqltime,0,0),array("lastloginip",Cls.getip,17,1))
				Cls.db.dbupdate "[sys_Admin]","adminid="&data(0,0)&"",datanew
				Cls.setsession "adminid",data(0,0)
				Cls.setsession "logintimes",data(1,0)
				Cls.setsession "lastlogindate",data(5,0)
				Cls.setsession "lastloginip",data(6,0)
				Cls.setsession "adminname",t0
				Cls.setsession "admingroupid",data(3,0)
				Cls.setcookie "adminid",data(0,0)
				Cls.setsession "penname",data(4,0)
				dim key:key=Cls.getkey()
				Cls.setcookie "adminid",data(0,0)
				Cls.setcookie "loginkey",key
				Cls.setcookie "loginpwd",md5(t0&md5(t1)&key)
				Cls.echo "1登录成功"
			end if
		end if
		data=""
	end sub
	
	
	sub logout()
		Cls.setsession "adminid",""
		Cls.setsession "adminname",""
		Cls.setsession "penname",""
		Cls.setsession "admingroupid",""
		Cls.setcookie "adminid",empty
		Cls.setcookie "loginkey",empty
		Cls.setcookie "loginpwd",empty
		Cls.go "login.asp"
	end sub
	
	sub main()
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>后台管理系统</title>
<link href="../Css/base.css" rel="stylesheet" type="text/css" />
<link href="../Css/public.css" rel="stylesheet" type="text/css" />
<link href="../Css/login.css" rel="stylesheet" type="text/css" />
<script language="javascript" src="../js/jquery.js"></script>
<script language="javascript" src="../js/jquery.artDialog.js?skin=default"></script>
<script language="javascript" src="../js/artDialog.iframeTools.js"></script>
<script language="javascript" src="../js/base.js"></script>
<script language="javascript" src="../js/admin.js"></script>
<script type="text/javascript">
$(function()
	{
		$(".u").focus(function(){$(this).addClass("input")});
		$(".c").focus(function(){$(this).addClass("input")});
		$(".u").blur(function(){$(this).removeClass("input")});
		$(".c").blur(function(){$(this).removeClass("input")});
		
	}
)
if(self!=top){top.location=self.location;}
</script>
</head>

<body>
    <div id="login">
        <div class="logo">
            <img src="../images/login_logo.gif" width="165" height="90" />
            <div class="menu"><a href="http://www.xxasp.net" class="a" target="_blank">官方网站</a><a href="http://www.xxasp.net/bbs" class="b" target="_blank">交流论坛</a></div>
        </div>
        <div class="login">
            <form onsubmit="return checklogin(this)">
            <dl>
                <dt>用户名：<input type="text" name="t0" id="t0" class="u" maxlength="20" /></dt>
                <dt>密　码：<input type="password" name="t1" id="t1" class="u" maxlength="20" /></dt>
                <dt>验证码：<input type="text" name="t2" id="t2" class="c" maxlength="4" /><img src="../Lib/imgcode.asp?t0=60&t1=14" title="看不清楚？点击刷新！" align="absmiddle" onClick="this.src+='&'+Math.random();" /></dt>
                <dd><input type="submit" value="登录" id="bnt" class="lbnt" /><input type="reset" value="重置" class="lbnt" /></dd>
            </dl>
            </form>
        </div>
    </div>
</body>
</html>
<%
end sub
%>